iT邦幫忙

2022 iThome 鐵人賽

DAY 26
0
Modern Web

Laravel 9 漫遊,享受魔法般的極速網頁開發體驗系列 第 26

Day 26:協助開發中除錯的好幫手:Laravel Telescope

  • 分享至 

  • xImage
  •  

到今天,基本上有關 Laravel 的功能,我們都做了一個基本的介紹。

不過,Laravel 之所以開發方便,除了原本就具備許多的功能以外,還有一個獨樹一格的地方,就是他非常豐富的官方套件們!

其中有幾個套件我們已經使用過了,像是安裝環境時所使用的 Laravel Sail,登入註冊功能時使用的 Laravel Breeze,以及 以前的文章 介紹過的 Laravel Dusk。

今天,我們來介紹一個新套件:Laravel telescope!

telescope 這個套件,基本上是用來協助開發中除錯用的

Laravel Telescope makes a wonderful companion to your local Laravel development environment. Telescope provides insight into the requests coming into your application, exceptions, log entries, database queries, queued jobs, mail, notifications, cache operations, scheduled tasks, variable dumps, and more.

這次,我們只在開發期間使用這個套件,所以特別指定只在 dev 環境下安裝

./vendor/bin/sail composer require laravel/telescope --dev

安裝好之後,我們要協助套件安裝一下環境:

./vendor/bin/sail artisan telescope:install

Publishing Telescope Service Provider...
Publishing Telescope Assets...
Publishing Telescope Configuration...
Telescope scaffolding installed successfully.

安裝環境之後,要設置一下資料庫,加上紀錄除錯資訊用的資料表。

./vendor/bin/sail artisan migrate

   INFO  Running migrations.  

  2018_08_08_100000_create_telescope_entries_table .................................................. 453ms DONE

都處理好之後,我們就可以開始使用我們的 telescope 囉!

首先我們看看設定,設定檔案已經安裝好了,在 config/telescope.php 裡面


'domain' => env('TELESCOPE_DOMAIN', null),

'path' => env('TELESCOPE_PATH', 'telescope'),

這邊我們沒有指定 domain,所以 telescope 會監視專案下所有的範圍。

path 下已經設定預設值為 telescope

所以,我們連線 http://127.0.0.1/telescope/ 的話,就會看到 telescope 的畫面了

telescope

是不是很方便呢?

透過 telescope 的協助,我們可以很直觀的看傳入專案的請求、資料庫的存取、甚至目前正在排程內的任務。對開發的除錯上面,可以說非常的有幫助。

今天有關 telescope 的簡單介紹就到這邊,各位明天見!


上一篇
Day 25:快取之外的加速方式:透過 queue 非同步的處理費時任務
下一篇
Day 27:協助確認並修正 coding style:Laravel Pint
系列文
Laravel 9 漫遊,享受魔法般的極速網頁開發體驗30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言